package com.qf.controller;

import com.qf.dto.VoucherDto;
import com.qf.pojo.Voucher;
import com.qf.service.VoucherService;
import com.qf.utils.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("voucher")
public class VoucherController {
    @Autowired
    private VoucherService voucherService;

    @RequestMapping("getList")
    @ResponseBody
    public Object getList(@RequestBody VoucherDto dto){
        Map<String, Object> data = voucherService.getList(dto);
       return ResponseUtil.ok(data);
    }


    @RequestMapping("delete")
    //不转跳视图页面 直接返回数据
    @ResponseBody
    public  Object delete(Integer id){
        voucherService.delete(id);
         return  ResponseUtil.ok(null);
    }

    @RequestMapping("add")
    //不转跳视图页面 直接返回数据
    @ResponseBody
    public  Object add(@RequestBody Voucher voucher){
       voucherService.add(voucher);
        return  ResponseUtil.ok();
    }

}
